package com.qf.mapper;


import com.qf.model.ProductBatches;
import org.apache.ibatis.annotations.*;

import java.util.List;


@Mapper
public interface ProductBatchesMapper {
    @Select("select * from product_batches")
    List<ProductBatches> selectAll();

    @Results(id = "ProductBatchesMap",value = {
                @Result(column = "id",property = "id"),
                @Result(column = "productName",property = "productName"),
                @Result(column = "isactive",property = "isactive"),
                @Result(column = "productBatch",property = "productBatch"),
                @Result(column = "feature",property = "feature"),
                @Result(column = "recoverydate",property = "recoverydate"),
                @Result(column = "userId",property = "userId"),
                @Result(column = "farmId",property = "farmId")

})

    @Select("select * from product_batches limit #{currentPage},#{pageSize}")
    List<ProductBatches> findPage(@Param("currentPage")Integer currentPage,@Param("pageSize")Integer pageSize);

    @Select("select count(*) from product_batches")
    Long count();

    @Insert("insert into product_batches (productName,isactive,productBatch,feature,recoverydate,userId,farmId) values (#{productName},#{isactive},#{productBatch},#{feature},#{recoverydate},#{userId},#{farmId})")
    int insertProduct(ProductBatches productBatches);

    @Select("select * from product_batches where id =#{id}")
    @ResultMap("ProductBatchesMap")
    ProductBatches findById(int id);
    @Update("update product_batches set productName=#{productName},isactive=#{isactive},productBatch=#{productBatch},feature=#{feature},recoverydate=#{recoverydate},userId=#{userId},farmId=#{farmId} where id=#{id}")
    int update(ProductBatches productBatches);
    @Delete("delete from product_batches where id =#{id}")
    int delById(Integer id);

}
